package com.example.test_umeng

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.umeng.analytics.MobclickAgent


class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)

    }

    fun login(view: View) {
        MobclickAgent.onProfileSignIn("18630704579")
        MobclickAgent.userProfileMobile("18630704579")
        MobclickAgent.userProfileEMail("developer@gmail.com")
        MobclickAgent.userProfile("key111", "val111")
        MobclickAgent.userProfile("key222", 123457878L)
        MobclickAgent.userProfile("key333", 0.0234 as Double)
    }
    fun logout(view: View) {
        MobclickAgent.onProfileSignOff();
    }

    override fun onResume() {
        super.onResume()
        MobclickAgent.onPageStart("main") //统计页面
    }

    override fun onPause() {
        super.onPause()
        MobclickAgent.onPageEnd("main") //统计页面
    }
    //事件埋点统计
    fun music(view: View) {
        val music: MutableMap<String, Any> = HashMap()
        music["music_type"] = "popular" //自定义参数：音乐类型，值：流行
        music["singer"] = "JJ" //歌手：(林俊杰)JJ
        music["song_name"] = "A_Thousand_Years_Later" //歌名：一千年以后
        music["song_price"] = 100 //价格：100元
        MobclickAgent.onEventObject(this, "play_music", music)
    }
}